using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;

using FreeFlow.Administration;

namespace FreeFlowAdministrator
{
	/// <summary>
	/// Summary description for ColumnsControl.
	/// </summary>
	public class ColumnsControl : System.Windows.Forms.UserControl
  {
    private FreeFlowAdministrator.ExtendedDataGrid columnsGrid;
    private UIActionsControl uiActionsControl;
    private IContainer components;

		public ColumnsControl()
		{
			// This call is required by the Windows.Forms Form Designer.
			InitializeComponent();

      UIActionList actions = new UIActionList();
      actions.Add("Copy to clipboard", "Copy the list of columns to the clipboard",
        new ActionExecuteDelegate(CopyToClipboard));
      uiActionsControl.Actions = actions;
		}

		/// <summary> 
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Component Designer generated code
		/// <summary> 
		/// Required method for Designer support - do not modify 
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
      this.components = new System.ComponentModel.Container();
      this.columnsGrid = new FreeFlowAdministrator.ExtendedDataGrid();
      this.uiActionsControl = new FreeFlowAdministrator.UIActionsControl();
      ((System.ComponentModel.ISupportInitialize)(this.columnsGrid)).BeginInit();
      this.SuspendLayout();
      // 
      // columnsGrid
      // 
      this.columnsGrid.AllowNavigation = false;
      this.columnsGrid.CaptionVisible = false;
      this.columnsGrid.DataMember = "";
      this.columnsGrid.Dock = System.Windows.Forms.DockStyle.Fill;
      this.columnsGrid.HeaderForeColor = System.Drawing.SystemColors.ControlText;
      this.columnsGrid.Location = new System.Drawing.Point(0, 0);
      this.columnsGrid.Name = "columnsGrid";
      this.columnsGrid.Size = new System.Drawing.Size(503, 423);
      this.columnsGrid.TabIndex = 0;
      // 
      // uiActionsControl
      // 
      this.uiActionsControl.Actions = null;
      this.uiActionsControl.Dock = System.Windows.Forms.DockStyle.Right;
      this.uiActionsControl.Location = new System.Drawing.Point(503, 0);
      this.uiActionsControl.Name = "uiActionsControl";
      this.uiActionsControl.Size = new System.Drawing.Size(150, 423);
      this.uiActionsControl.TabIndex = 1;
      // 
      // ColumnsControl
      // 
      this.Controls.Add(this.columnsGrid);
      this.Controls.Add(this.uiActionsControl);
      this.Name = "ColumnsControl";
      this.Size = new System.Drawing.Size(653, 423);
      ((System.ComponentModel.ISupportInitialize)(this.columnsGrid)).EndInit();
      this.ResumeLayout(false);

    }
		#endregion

    public void LoadColumns(ColumnCollection columns)
    {
      columnsGrid.DataSource = columns;
      columnsGrid.ClearColumns();
      columnsGrid.AddColumn("Name");
      columnsGrid.AddColumn("DatabaseType", "Database type");
      columnsGrid.AddColumn("Size");
      columnsGrid.AutosizeColumns();
    }

    private string CopyToClipboard()
    {
      columnsGrid.CopyToClipboard();
      return null;
    }
	}
}
